home *** CD-ROM | disk | FTP | other *** search
- !!Script
- // Copyright ⌐ 1997-1998 - Modelworks Software
-
- // Insert script helper for:
-
- /**
- @Object: Editor
- @Method: getHtmlTag(startLineIndex, startCharIndex) returns a List object containing
- a list of the tag's attributes and values Each item in the list is an Association object
- containing a Token object for the key and the value. Note: The first item contains the
- name of the tag and has no value and the name of the list is set to the
- tag name (.e.g., for the tag "<A ...>" the name is "A") The method returns null if
- the specified location is not the beginning of a HTML tag (e.g., '<').
- Example: the tag "<A NAME='target'>" has the following two items in the list
- item 1: Association [ Token ["A", lineIndex, charIndex], Token ["", lineIndex, charIndex]]]
- item 2: Association [ Token ["NAME", lineIndex, charIndex], Token ["target", lineIndex, charIndex]]]
- @Syntax: editor.getHtmlTag(startLineIndex, startCharIndex)
- @Example: Example: List all anchor tags in an editor with a "HREF" field
- var editor = getActiveEditor();
- var findData = editor.findFirst("<A", 0, 0, true, false, false);
- if (findData)
- {
- while (findData.found)
- {
- var attributeList = editor.getHtmlTag(findData.range.startLineIndex, findData.range.startCharIndex);
- if (attributeList)
- {
- var position = attributeList.getHeadPosition();
- while (position.valid)
- {
- // attribute.key and attribute.value are Token objects
- var attribute = attributeList.getNext(position);
- if (attribute.key.string.toUpperCase() == "HREF")
- {
- var lineData = editor.copy(findData.range.startLineIndex);
- output.writeMessage(editor.path, findData.range.startLineIndex, lineData);
- break;
- }
- }
- }
- editor.findNext(findData);
- }
- }
- @Summary: getHtmlTag - returns a List object containing the tag's attributes
- */
-
- function DoCommand()
- {
- var editor = getActiveEditor();
- if (editor)
- {
- var selection = editor.getSelection();
- editor.replace("editor.getHtmlTag(startLineIndex, startCharIndex);", selection);
- editor.setActive("Insert editor.getHtmlTag");
- }
- }
-
- !!/Script
-